<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>软件园商城 - 登录</title>
  <!-- Bootstrap core CSS -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <!-- Font Awesome for icons -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
  <!-- Custom styles for this template -->
  <style type="text/css">
    body {
      display: flex;
      justify-content: center;
      align-items: center;
      min-height: 100vh;
      margin: 0;
      background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    }

    .form-signin {
      width: 100%;
      max-width: 350px;
      padding: 1.5rem;
      background-color: white;
      border-radius: 12px;
      box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
      opacity: 0;
      transform: translateY(20px);
      animation: fadeIn 0.8s forwards;
    }

    @keyframes fadeIn {
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    .form-signin .logo {
      width: 80px;
      height: 80px;
      margin: 0 auto 1rem;
      border-radius: 50%;
      overflow: hidden;
      border: 2px solid #4a6bff;
      box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    }

    .form-signin .logo img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .form-signin h1 {
      margin-bottom: 1rem;
      color: #4a6bff;
      font-weight: 600;
      font-size: 1.5rem;
    }

    .form-signin .form-control {
      position: relative;
      box-sizing: border-box;
      height: auto;
      padding: 10px;
      font-size: 14px;
      margin-bottom: 15px;
      border: 1px solid #ddd;
      border-radius: 8px;
      transition: all 0.3s;
    }

    .form-signin .form-control:focus {
      z-index: 3;
      border-color: #4a6bff;
      box-shadow: 0 0 0 3px rgba(74, 107, 255, 0.25);
    }

    .form-signin .btn-primary {
      background-color: #4a6bff;
      border-color: #4a6bff;
      border-radius: 8px;
      font-weight: 600;
      padding: 10px;
      margin-top: 10px;
      transition: all 0.3s;
    }

    .form-signin .btn-primary:hover {
      background-color: #3a5ae8;
      border-color: #3a5ae8;
    }

    .form-signin .register-link {
      display: block;
      text-align: center;
      margin-top: 15px;
      color: #4a6bff;
      text-decoration: none;
      font-size: 14px;
    }

    .form-signin .register-link:hover {
      text-decoration: underline;
    }

    .form-signin .error-message {
      color: #dc3545;
      font-size: 14px;
      margin-bottom: 15px;
    }

    .form-signin .social-login {
      margin-top: 20px;
      text-align: center;
    }

    .form-signin .social-btn {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      display: inline-flex;
      justify-content: center;
      align-items: center;
      margin: 0 8px;
      color: white;
      font-size: 18px;
      transition: all 0.3s;
    }

    .form-signin .social-btn:hover {
      transform: translateY(-3px);
      box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
    }

    .form-signin .divider {
      display: flex;
      align-items: center;
      margin: 15px 0;
      color: #6c757d;
      font-size: 14px;
    }

    .form-signin .divider::before,
    .form-signin .divider::after {
      content: "";
      flex: 1;
      border-bottom: 1px solid #ddd;
    }

    .form-signin .divider::before {
      margin-right: 10px;
    }

    .form-signin .divider::after {
      margin-left: 10px;
    }

    .form-signin .footer {
      margin-top: 20px;
      font-size: 12px;
      color: #6c757d;
    }
  </style>
</head>
<body class="text-center">
<div class="container">
  <form class="form-signin" action="#" th:action="@{/login}" method="post" id="loginForm">
    <!-- 头像区域 -->
    <div class="logo">
      <img id="userAvatar" th:src="@{/img/bootstrap-solid.svg}" alt="用户头像">
    </div>

    <h1 class="h3 mb-3 font-weight-normal">欢迎登录</h1>

    <!-- 错误信息 -->
    <p class="error-message" th:if="${not #strings.isEmpty(msg)}" th:text="${msg}"></p>

    <label class="sr-only">用户名</label>
    <input type="text" name="name" class="form-control" placeholder="用户名" required="" autofocus=""
           id="username">

    <label class="sr-only">密码</label>
    <input type="password" name="password" class="form-control" placeholder="密码" required=""
           id="password">

    <button class="btn btn-lg btn-primary btn-block" type="submit">登录</button>

    <a class="register-link" th:href="@{/toRegister}">没有账号？请注册</a>

    <!-- 社交登录 -->
    <div class="divider">
      <span>或</span>
    </div>

    <div class="social-login">
      <a href="#" id="qqLoginBtn" class="social-btn" style="background-color: #12b7f5;">
        <i class="fab fa-qq"></i>
      </a>
      <a href="#" class="social-btn" style="background-color: #07c160;">
        <i class="fab fa-weixin"></i>
      </a>
    </div>

    <p class="footer">© 2022-2026 软件园商城</p>
  </form>
</div>

<!-- JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<script>
  document.getElementById('qqLoginBtn').addEventListener('click', function(e) {
    e.preventDefault();

    // 替换为你的AppID
    const appId = 'YOUR_APP_ID';

    // 替换为你的回调URL
    const redirectUri = encodeURIComponent('http://localhost:8080/auth/qq/callback');

    // 构建QQ授权URL
    const qqAuthUrl = `https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=${appId}&redirect_uri=${redirectUri}&scope=get_user_info&state=STATE`;

    // 跳转到QQ授权页面
    window.location.href = qqAuthUrl;
  });
</script>
</body>
</html>